package com.kangkang.creationalpattern;

public class Singleton2 {
    /*
     * 懒汉式创建单例模式 由于懒汉式是非线程安全， 所以加上线程锁保证线程安全
     */
    private static Singleton2 singleton;

    private Singleton2() {
    }

    public static synchronized Singleton2 getInstance() {
        if (singleton == null) {
            singleton = new Singleton2();
        }
        return singleton;
    }
}
